stylecontext: Fix cache updating
authorBenjamin Otte <otte@redhat.com>
Tue, 23 Dec 2014 07:19:39 +0000 (08:19 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 7 Jan 2015 13:26:48 +0000 (14:26 +0100)
After the parent changes in commit
3a337156d11a86c7a88f1f30a09276fdf6f63008 we need to refresh the cached
styles after the current style. After all, they now depend on the base
style.

gtk/gtkstylecontext.c

index e0d43767756c607db02f88840df9a5a9bd3a469a..1e6bd427686e6d4e7d5995d5797ad2467e9a95e8 100644 (file)
@@ -2675,33 +2675,6 @@ gtk_style_context_clear_cache (GtkStyleContext *context)
   gtk_style_context_clear_property_cache (context);
 }
 
-static void
-gtk_style_context_update_cache (GtkStyleContext  *context,
-                                const GtkBitmask *parent_changes)
-{
-  GtkStyleContextPrivate *priv;
-  GHashTableIter iter;
-  gpointer key, value;
-
-  if (_gtk_bitmask_is_empty (parent_changes))
-    return;
-
-  priv = context->priv;
-
-  g_hash_table_iter_init (&iter, priv->style_values);
-  while (g_hash_table_iter_next (&iter, &key, &value))
-    {
-      const GtkCssNodeDeclaration *decl = key;
-      GtkCssStyle *values = value;
-
-      values = update_properties (context, values, decl, parent_changes);
-
-      g_hash_table_iter_replace (&iter, values);
-    }
-
-  gtk_style_context_clear_property_cache (context);
-}
-
 static void
 gtk_style_context_do_invalidate (GtkStyleContext  *context,
                                  const GtkBitmask *changes)
@@ -2742,6 +2715,41 @@ gtk_style_context_style_needs_full_revalidate (GtkCssStyle  *style,
     return FALSE;
 }
 
+static void
+gtk_style_context_update_cache (GtkStyleContext  *context,
+                                GtkCssChange      change,
+                                const GtkBitmask *parent_changes)
+{
+  GtkStyleContextPrivate *priv;
+  GHashTableIter iter;
+  gpointer key, value;
+
+  if (_gtk_bitmask_is_empty (parent_changes))
+    return;
+
+  priv = context->priv;
+
+  g_hash_table_iter_init (&iter, priv->style_values);
+  while (g_hash_table_iter_next (&iter, &key, &value))
+    {
+      const GtkCssNodeDeclaration *decl = key;
+      GtkCssStyle *style = value;
+
+      if (gtk_style_context_style_needs_full_revalidate (style, change))
+        {
+          g_hash_table_iter_remove (&iter);
+        }
+      else
+        {
+          style = update_properties (context, style, decl, parent_changes);
+
+          g_hash_table_iter_replace (&iter, style);
+        }
+    }
+
+  gtk_style_context_clear_property_cache (context);
+}
+
 static gboolean
 gtk_style_context_should_create_transitions (GtkStyleContext *context)
 {
@@ -2816,8 +2824,6 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     {
       GtkCssStyle *values;
 
-      gtk_style_context_clear_cache (context);
-
       style_info_set_values (info, NULL);
       values = style_values_lookup (context);
 
@@ -2835,8 +2841,6 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     }
   else
     {
-      gtk_style_context_update_cache (context, parent_changes);
-
       if (!_gtk_bitmask_is_empty (parent_changes))
         {
           GtkCssStyle *new_values;
@@ -2891,6 +2895,9 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     gtk_style_context_do_invalidate (context, changes);
 
   change = _gtk_css_change_for_child (change);
+  
+  gtk_style_context_update_cache (context, change, changes);
+
   for (list = priv->children; list; list = list->next)
     {
       _gtk_style_context_validate (list->data, timestamp, change, changes);